//package com.plian.system.controller.hr.management;
//
//import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
//import com.baomidou.mybatisplus.core.metadata.IPage;
//import com.plian.Tools.Func;
//import com.plian.Tools.StringPool;
//import com.plian.Tools.TokenUtil;
//import com.plian.Tools.base.BaseController;
//import com.plian.Tools.pagedata.PageData;
//import com.plian.system.dto.hr.management.ManagementAppointDTO;
//import com.plian.system.entity.hr.management.ManagementAppointment;
//import com.plian.system.model.CommonCode;
//import com.plian.system.model.ListResult;
//import com.plian.system.model.ObjResult;
//import com.plian.system.model.R;
//import com.plian.system.mybatis.search.SearchEntity;
//import com.plian.system.mybatis.search.SearchParamEntiy;
//import com.plian.system.mybatis.support.Condition;
//import com.plian.system.mybatis.support.Query;
//import com.plian.system.service.hr.management.IManagementAppointmentService;
//import com.plian.system.service.wf.FormWorkflowService;
//import com.plian.system.vo.hr.management.ManagementAppointmentVO;
//import com.plian.system.wrapper.hr.management.ManagementAppointWrapper;
//import lombok.AllArgsConstructor;
//import lombok.extern.slf4j.Slf4j;
//import org.apache.commons.lang3.StringUtils;
//import org.springframework.web.bind.annotation.PostMapping;
//import org.springframework.web.bind.annotation.RequestBody;
//import org.springframework.web.bind.annotation.RequestMapping;
//import org.springframework.web.bind.annotation.RestController;
//
//import javax.servlet.http.HttpServletResponse;
//import java.util.HashMap;
//import java.util.List;
//
///**
// * @author panqb
// * @version 1.0
// * @description: 经理层聘用 控制器
// * @date 2022/4/2 下午1:50
// */
//@Slf4j
//@RestController
//@AllArgsConstructor
//@RequestMapping("api/managementappointment")
//public class ManagementAppointController extends BaseController {
//
//    IManagementAppointmentService managementAppointmentService;
//
//    private FormWorkflowService formWorkflowService;
//
//    ManagementAppointWrapper managementAppointWrapper;
//
//    /**
//     * 保存方法
//     * @param managementAppointDTO
//     * @return
//     */
//    @PostMapping("submit")
//    public ObjResult save(@RequestBody  ManagementAppointDTO managementAppointDTO){
//        boolean result=managementAppointmentService.submit(managementAppointDTO);
//        HashMap<String, Object> processVariable = new HashMap<>();
//        formWorkflowService.startProcessAndSimulate(String.valueOf(managementAppointDTO.getId()),managementAppointDTO.getFormType(),processVariable);
//        return result ? new ObjResult(CommonCode.SUCCESS) : new ObjResult(CommonCode.FAIL);
//    }
//
//
//    /**
//     * 详情
//     * @param managementAppointDTO
//     * @return
//     */
//    @PostMapping("detail")
//    public R<ManagementAppointmentVO> detail(@RequestBody ManagementAppointDTO managementAppointDTO){
//        R<ManagementAppointmentVO> result=new R<>(CommonCode.SUCCESS);
//        QueryWrapper queryWrapper=new QueryWrapper();
//        queryWrapper.eq("id",managementAppointDTO.getId());
//        ManagementAppointment managementAppointment=managementAppointmentService.getOne(queryWrapper);
//        ManagementAppointmentVO managementAppointmentVO=managementAppointWrapper.entityToVO(managementAppointment);
//        result.setPageData(managementAppointmentVO);
//        return result;
//    }
//
//    /**
//     * 列表
//     * @param query
//     * @return
//     */
//    @PostMapping("list")
//    public ListResult<ManagementAppointmentVO> list(@RequestBody Query query){
//        List<SearchEntity> entityList = query.getSearch();
//        QueryWrapper<ManagementAppointment> queryWrapper = SearchParamEntiy.getQueryWrapper(
//                Condition.getQueryWrapper(new ManagementAppointment()), entityList
//        );
//        if (query.getIsReport()==null){
//            queryWrapper.eq("create_company_id", TokenUtil.getTokenOrgId());
//            queryWrapper.orderByAsc(" IFNULL(order_number,9999)+0").orderByDesc("create_time");
//        }else{
//            queryWrapper.eq("status","3");
//            queryWrapper.orderByAsc(" IFNULL(order_number,9999)+0").orderByAsc("org_gradation");
//        }
//        IPage<ManagementAppointment> pages = managementAppointmentService.page(Condition.getPage(query), queryWrapper);
//        ListResult<ManagementAppointmentVO> listResult = new ListResult<>(CommonCode.SUCCESS);
//        listResult.setList(managementAppointWrapper.entityToVO(pages.getRecords()));
//        listResult.setTotal(Long.valueOf(pages.getTotal()).intValue());
//        return listResult;
//    }
//
//    /**
//     * 列表
//     * @param query
//     * @return
//     */
//    @PostMapping("report")
//    public ListResult<ManagementAppointmentVO> report(@RequestBody Query query){
//        List<SearchEntity> entityList = query.getSearch();
//        QueryWrapper<ManagementAppointment> queryWrapper = SearchParamEntiy.getQueryWrapper(
//                Condition.getQueryWrapper(new ManagementAppointment()), entityList
//        );
//        queryWrapper.eq("status","3");
//        List<ManagementAppointment> managementAppointmentList=managementAppointmentService.list(queryWrapper);
//        ListResult<ManagementAppointmentVO> listResult = new ListResult<>(CommonCode.SUCCESS);
//        List<ManagementAppointmentVO> managementAppointmentVOList=managementAppointWrapper.entityToVO(managementAppointmentList);
//        List<ManagementAppointmentVO> resultList=managementAppointmentService.report(managementAppointmentVOList);
//        listResult.setList(resultList);
//        listResult.setTotal(resultList.size());
//        return listResult;
//    }
//
//    /**
//     * 删除
//     */
//    @PostMapping("/remove")
//    public ObjResult remove(@RequestBody PageData pd) {
//        List<String> ids = (List<String>)pd.get("ids");
//        return managementAppointmentService.deleteLogic(Func.toLongList(StringUtils.join(ids, StringPool.COMMA)))
//                ? new ObjResult(CommonCode.SUCCESS) : new ObjResult(CommonCode.FAIL);
//    }
//
//    /**
//     * 报表导出
//     * @param query
//     * @param response
//     */
//    @PostMapping("/exportExcel")
//    public void exportExcel(@RequestBody Query query, HttpServletResponse response){
//        managementAppointmentService.exportExcel(query,response);
//    }
//
//}
